﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;

namespace MG1
{
    class SpriteBase
    {
        public Vector2 position = new Vector2(0, 0);
        public Texture2D texture;
        public string assetName;
        public Rectangle size;

        float scale = 1.0f;
        Rectangle sourceSize;

        public float Scale
        {
            get { return scale; }
            set
            {
                scale = value;
                size = new Rectangle(0, 0, (int)(SourceSize.Width * scale), (int)(SourceSize.Height * scale));
            }
        }
        public Rectangle SourceSize
        {
            get { return sourceSize; }
            set
            {
                sourceSize = value;
                size = new Rectangle(0, 0, (int)(sourceSize.Width * Scale), (int)(sourceSize.Height * Scale));
            }
        }

        public void LoadContent(ContentManager _contentManager, string _assetName)
        {
            texture = _contentManager.Load<Texture2D>(_assetName);
            assetName = _assetName;
            SourceSize = new Rectangle(0, 0, texture.Width, texture.Height);
            size = new Rectangle(0, 0, (int)(texture.Width * Scale), (int)(texture.Height * Scale));
        }

        public void Update(GameTime theGameTime)
        {

        }

        public void Draw(SpriteBatch theSpriteBatch)
        {
            theSpriteBatch.Draw(texture, position, SourceSize, Color.White, 0.0f, Vector2.Zero, Scale, SpriteEffects.None, 0);
        }

    }
}
